package com.cgy.utils.jmx.jvm.bean;

import com.cgy.utils.jmx.IJvmInfoFactory;

import javax.management.ObjectName;
import java.lang.management.ClassLoadingMXBean;
import java.lang.management.ManagementFactory;

/**
 * @author CHTK
 */
public class BeanJmxFactory extends IJvmInfoFactory {

    @Override
    public void status() {
        ClassLoadingMXBean classLoadingMXBean = ManagementFactory.getClassLoadingMXBean();

        int loadedClassCount = classLoadingMXBean.getLoadedClassCount();
        long totalLoadedClassCount = classLoadingMXBean.getTotalLoadedClassCount();
        long unloadedClassCount = classLoadingMXBean.getUnloadedClassCount();

        put("class.jvm.sumsize", loadedClassCount, "Java 虚拟机加载的类的总数");
        put("class.jvm.unloadedsize", unloadedClassCount, "Java 虚拟机未加载的类的总数");
        put("class.jvm.loadedsize", totalLoadedClassCount, "Java 虚拟机开始执行到目前已经卸载的类的总数");

        ObjectName objectName = classLoadingMXBean.getObjectName();
    }
}
